﻿Imports System
Imports System.Windows
Imports System.Windows.Controls

Partial Public Class Demo
    Inherits Page

    Private _vm As DemoViewModel

    Public Sub New()
        InitializeComponent()
        AddHandler Me.Loaded, AddressOf Me.Demo_Loaded
    End Sub

    Sub Demo_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me._vm = New DemoViewModel(New Uri("/products/list", UriKind.Relative), New Uri("/products/edit", UriKind.Relative), New Uri("/products/persist", UriKind.Relative))

        Me.DataContext = Me._vm

        Me._vm.GetProducts()
    End Sub

    Private Sub productsGrid_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Me._vm.GetSelectedProduct((DirectCast(e.AddedItems(0), ProductListView)).ProductId)
    End Sub

    Private Sub saveButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me._vm.Persist()
    End Sub

End Class
